
package com.insigma.business.qrcode.common.converter;

import com.insigma.business.qrcode.merchant.dto.CareWelfareMerchantEntryApplyDTO;
import com.insigma.business.qrcode.merchant.dto.CareWelfareMerchantEntryApplyExportVO;
import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantEntryApplyInsertRequest;
import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantEntryApplySearchRequest;
import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantEntryApplyUpdateRequest;
import com.insigma.business.qrcode.merchant.dto.search.CareWelfareMerchantEntryApplyBSearcher;
import com.insigma.business.qrcode.merchant.entity.CareWelfareMerchantEntryApply;
import com.insigma.business.qrcode.soldier.dto.StatsDataTypeEnum;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;


public class CareWelfareMerchantEntryApplyProviderConverter extends AbstractConverter<CareWelfareMerchantEntryApplyDTO, CareWelfareMerchantEntryApply> {

    private final static CareWelfareMerchantEntryApplyProviderConverter careWelfareMerchantEntryApplyConverter = new CareWelfareMerchantEntryApplyProviderConverter();

    private CareWelfareMerchantEntryApplyProviderConverter(){}

    
    public static CareWelfareMerchantEntryApplyBSearcher convertRequestSO2Searcher(final CareWelfareMerchantEntryApplySearchRequest request){
        final CareWelfareMerchantEntryApplyBSearcher careWelfareMerchantEntryApplyBSearcher = new CareWelfareMerchantEntryApplyBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,careWelfareMerchantEntryApplyBSearcher);
        return careWelfareMerchantEntryApplyBSearcher;
    }

    
    public static CareWelfareMerchantEntryApply convertRequestUO2DO(final CareWelfareMerchantEntryApplyUpdateRequest careWelfareMerchantEntryApplyUpdateRequest) {
        final CareWelfareMerchantEntryApply careWelfareMerchantEntryApply = new CareWelfareMerchantEntryApply();
        BeanUtils.copyProperties(careWelfareMerchantEntryApplyUpdateRequest,careWelfareMerchantEntryApply);
        
        return careWelfareMerchantEntryApply;
    }

    
    public static CareWelfareMerchantEntryApply convertRequestIO2DO(final CareWelfareMerchantEntryApplyInsertRequest careWelfareMerchantEntryApplyInsertRequest) {
        final CareWelfareMerchantEntryApply careWelfareMerchantEntryApply = new CareWelfareMerchantEntryApply();
        BeanUtils.copyProperties(careWelfareMerchantEntryApplyInsertRequest,careWelfareMerchantEntryApply);
        return careWelfareMerchantEntryApply;
    }

    
    public static List<CareWelfareMerchantEntryApplyDTO> convertResponseDOList2DTOList(final List<CareWelfareMerchantEntryApply> careWelfareMerchantEntryApplyList){
        return careWelfareMerchantEntryApplyConverter.convertGenericResponseDOList2DTOList(careWelfareMerchantEntryApplyList);
    }

    
    public static CareWelfareMerchantEntryApplyDTO convertResponseDO2DTO(final CareWelfareMerchantEntryApply careWelfareMerchantEntryApply){
        return careWelfareMerchantEntryApplyConverter.convertGenericResponseDO2DTO(careWelfareMerchantEntryApply);
    }

    public static List<CareWelfareMerchantEntryApplyExportVO> convertResponseDOList2ExportVOList(final List<CareWelfareMerchantEntryApply> careWelfareMerchantEntryApplyList){
        List<CareWelfareMerchantEntryApplyExportVO> list = new ArrayList<>();
        for(CareWelfareMerchantEntryApply doEntity: careWelfareMerchantEntryApplyList){
            CareWelfareMerchantEntryApplyExportVO careWelfareMerchantEntryApplyExportVO = new CareWelfareMerchantEntryApplyExportVO();
            BeanUtils.copyProperties(doEntity,careWelfareMerchantEntryApplyExportVO);
            careWelfareMerchantEntryApplyExportVO.setStatus(StatsDataTypeEnum.getByEnumName(careWelfareMerchantEntryApplyExportVO.getStatus())==null?careWelfareMerchantEntryApplyExportVO.getStatus():StatsDataTypeEnum.getByEnumName(careWelfareMerchantEntryApplyExportVO.getStatus()).getDesc());
            careWelfareMerchantEntryApplyExportVO.setAdminAreaCode(doEntity.getAdminAreaText());
            list.add(careWelfareMerchantEntryApplyExportVO);
        }
        return list;
    }


    @Override
    protected CareWelfareMerchantEntryApplyDTO doConvertResponseDO2DTO(CareWelfareMerchantEntryApply careWelfareMerchantEntryApply) {
        final CareWelfareMerchantEntryApplyDTO careWelfareMerchantEntryApplyDTO = new CareWelfareMerchantEntryApplyDTO();
        try {
            BeanUtils.copyProperties(careWelfareMerchantEntryApply, careWelfareMerchantEntryApplyDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return careWelfareMerchantEntryApplyDTO;
    }

}
